home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mflms101.arc / TC.C < prev    next >
C/C++ Source or Header  |  1989-11-25  |  2KB  |  81 lines

  1. /*
  2. **                TEXT COMPARE UTILITY
  3. **
  4. **   Copyright 1988-89, S.E. Margison
  5. **
  6. **   Modified 1989 by Bob Stout
  7. **
  8. **   This short utility compares two text files and shows
  9. **   any line differences.
  10. **
  11. **   As distributed, this program requires (for compilation):
  12. **     "The MicroFirm Function LIbrary for MS/QC"
  13. **   which may be obtained without registration from many Bulletin
  14. **   Board Systems.
  15. **
  16. **   or by registration:
  17. **      $25 for Docs, C, S, M, L, H libraries, and complete library source
  18. **              in C and Assembler
  19. **     MicroFirm
  20. **     P.O. Box 428
  21. **     Alief, TX 77411
  22. **
  23. **
  24. */
  25.  
  26. #include <stdio.h>
  27. #include <string.h>
  28. #include <mflstrng.h>
  29. #include <mflsys.h>
  30. #include <mflfiles.h>
  31.  
  32. #define MAXLINE 192
  33.  
  34. FILE *fp1, *fp2;
  35. char buf1[MAXLINE], buf2[MAXLINE];
  36.  
  37. main(argc, argv)
  38. int argc;
  39. char *argv[];
  40. {
  41.         int lc, end1, end2;
  42.         lc = 0;
  43.         end1 = end2 = FALSE;
  44.  
  45.         if(argc != 3)
  46.                 error("usage: TC file1 file2");
  47.  
  48.         if((fp1 = fopen(argv[1], "r")) == NULL) cant(argv[1]);
  49.  
  50.         if((fp2 = fopen(argv[2], "r")) == NULL)
  51.         {
  52.                 fclose(fp1);
  53.                 cant(argv[2]);
  54.         }
  55.  
  56.         for EVER
  57.         {
  58.                 ++lc;
  59.                 if(fgets(buf1, MAXLINE, fp1) == NULL)
  60.                         end1 = TRUE;
  61.                 if(fgets(buf2, MAXLINE, fp2) == NULL)
  62.                         end2 = TRUE;
  63.                 if(end1 || end2)
  64.                         break;
  65.  
  66.                 if(strcmp(buf1, buf2))
  67.                 {
  68.                         printf("Line %d in %s\n", lc, argv[1]);
  69.                         printf("%s", buf1);
  70.                         printf("Line %d in %s\n", lc, argv[2]);
  71.                         printf("%s", buf2);
  72.                 }
  73.         }
  74.         if(end1 && !end2)
  75.                 printf("EOF on %s occured first\n", argv[1]);
  76.         if(end2 && !end1)
  77.                 printf("EOF on %s occured first\n", argv[2]);
  78.         fclose(fp1);
  79.         fclose(fp2);
  80. }
  81.